﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;

namespace PeisongWeb
{
    public partial class seller_reportReceivablesList : customerPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (allowAccess(Convert.ToInt32(companyType.Provider)))
                {
                    rptBind();

                }
                else
                {
                    Library.Script.ClientUrl("index.html");
                    return;
                }

            }
        }

        void rptBind()
        {
            int sellerId = logic.customer.getCompanyId();
            StringBuilder where = new StringBuilder();
            where.Append("type='2' and companyId=" + sellerId);

            if (ext_StartInputDt.SelectedDate != DateTime.MinValue && ext_StartInputDt.Value.ToString() != "")
                where.AppendFormat(" and datediff(day,[startDt],'{0}')<=0", ext_StartInputDt.Value.ToString());
            if (ext_EndInputDt.SelectedDate != DateTime.MinValue && ext_EndInputDt.Value.ToString() != "")
                where.AppendFormat(" and datediff(day,[endDt],'{0}')<=0", ext_EndInputDt.Value.ToString());
            DataSet ds = logic.paymentHistory.select(where.ToString(), "payId desc", AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex); ;
            AspNetPager1.RecordCount = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
            rpt_list.DataSource = ds.Tables[1];
            rpt_list.DataBind();

        }
        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            rptBind();
        }
        protected void lbtn_Search_Click(object sender, EventArgs e)
        {
            rptBind();
        }
    }
}
